import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
  {
    path: "/",
    name: "Layout",
    component: () => import("../views/Layout"),
    children: [
      {
        path: "",
        name: "Home",
        component: () => import("../views/Home"),
      },
      {
        path: "/category/:id",
        name: "Category",
        component: () => import("../views/Category"),
      },
      {
        path: "/category/sub/:id",
        component: () => import("@/views/Category/Sub"),
      },
      {
        path: "/goods/:id",
        component: () => import("@/views/Goods"),
      },
      {
        path: "/cart",
        component: () => import("@/views/cart"),
      },
      {
        path: '/settlement',
        component: () => import('@/views/Settlement')
      },
      {
        path: '/pay',
        component: () => import('@/views/pay')
      },
      {
        path: '/pay/callback',
        component: () => import('@/views/pay/callback')
      },
      
    ],
  },
  {
    path: "/about",
    name: "about",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
  {
    path: "/login",
    name: "login",
    component: () => import(/* webpackChunkName: "about" */ "../views/login"),
  },
  {
    path: "/playGround",
    name: "playGround",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/playGround"),
  },
  {
    path: "/login/callback",
    name: "callback",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/login/callback"),
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  // 刷新行为时，回到顶部
  scrollBehavior: () => ({ x: 0, y: 0 }),
});

export default router;
